<?php
include('config.php');
include(PUNG_ROOT . '/system/header.php');

if(isset($_GET['id']))
{
	if(is_numeric($_GET['id']))
	{
		$id = $_GET['id'];
		$sql = $db -> db_query("SELECT * FROM " . DB_PREFIX . "content WHERE id = '$id'");
		$rows = $db -> db_rows();
		$sql =  $db -> db_result();
		$sql = $sql['0'];
		
		if($rows > 0)
		{
			$contitle = stripslashes($sql['title']);
			$context = stripslashes($sql['content']);
			
			$content = "
			<h2>$contitle</h2>
			$context<br />
			";
			
			if(!empty($sql['keywords'])){ $keywords = $sql['keywords'];}
			if(!empty($sql['description'])){ $description = $sql['description'];}
			
			$pagetitle = $pagetitle . ' | ' . stripslashes($sql['title']);
			
			$rss = 'rss.php';
		}
		else
		{
			$content = '<h2>' . CONTENT_013 . '</h2>' . CONTENT_014;
		}
	}
	else
	{
		$content = '<h2>' . CONTENT_013 . '</h2>' . CONTENT_014;
	}
}
else
{
	$sql = $db -> db_query("SELECT id FROM " . DB_PREFIX . "content 
	WHERE front = 'yes' LIMIT 1");
	$rows = $db -> db_rows();
	$sql = $db -> db_result();
	
	if($rows > 0)
	{
		header('Location: index.php?id=' . $sql['0']['id']);
	}
	else
	{
		$content = '<h2>' . CONTENT_013 . '</h2>' . CONTENT_014;
	}
}

include(PUNG_ROOT . '/system/footer.php');
?>